﻿using System.Collections.Generic;
using System.Linq;
using System.Web.Http;
using WebApi.API.Models;

namespace WebApi.API.Controllers
{
    public class UserController : ApiController
    {
        List<User> users = new List<User>
        {
            new User{ Id = "001",Name = "John"},
            new User{ Id = "002",Name = "Tom"}
        };
        [HttpGet]
        public IHttpActionResult GetUser(string id)
        {
            var dd = users.FirstOrDefault(c => c.Id == id);
            return Json(users.FirstOrDefault(c=>c.Id == id));
        }
        [HttpGet]
        public IHttpActionResult GetUserByName([FromUri]User user)
        {
            return Json(users.FirstOrDefault(c => c.Id == user.Id));
        }
        [HttpPost]
        public IHttpActionResult PostUserByName(User user)
        {
            return Json(users.FirstOrDefault(c => c.Id == user.Id));
        }
    }
}
